'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url api/pub/QueryWatchword 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid, watchword } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		console.log("userInfo=", userInfo);
		res.query = await db.collection('a_watchword').where({ watchword: watchword }).get()

		if (res.query.data.length == 1 && userInfo._id) {
			//更新用户的source_id
			let update_user_sourceid = await db.collection('uni-id-users').doc(userInfo._id).update({
				source_id: res.query.data[0].source_id,
				source_id_logtime: new Date().getTime()
			})
		}

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
